<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<% 
	String context = request.getContextPath(); 
%>
<html>
<head>
<title>组织机构</title>
<link rel="stylesheet" type="text/css" href="<%=context %>/Source/lib/ligerUI/skins/ligerui-icons.css" />
<link rel="stylesheet" type="text/css" href="<%=context %>/Source/lib/ligerUI/skins/Aqua/css/ligerui-all.css" />

</head>

<body style="padding: 0;overflow:hidden;">
<form id="searchForm" onsubmit="return false">
    <div id="layout1" style="margin: -1px">
        <div position="left" title="组织机构" style="height: 96%;overflow:auto;">
            <div id="orgDiv" style="width: 250px; height: 100%; margin: -1px; float: left; border: 1px solid #ccc; overflow: auto;">
                <ul id="tree1"></ul>
            </div>
        </div>
        <div position="center">
            <div id="toolbar"></div>
            <div id="mainGrid"></div>
        </div>
    </div>
</form>
</body>
<script src="<%=context %>/gooflow/jquery.min.js"></script>
<script src="<%=context %>/Source/lib/ligerUI/js/ligerui.all.js"></script>
<script type="text/javascript">
var path = '<%=context %>';
var _path = path+"/bap/organization";
$(function () {
    $("#layout1").ligerLayout({ leftWidth: 130, allowLeftResize: false, allowLeftCollapse: true, space: 2, heightDiff: -1 });
    $("#tree1").ligerTree({
        url: _path + '/tree?rnd=' + Math.random(),
        onSelect: onSelect,
        onCancelselect: onCancelselect,
        attribute: ['id'],
        checkbox: false
    });
    $("#mainGrid").ligerGrid({
        columns: [
            { display: 'id', name: 'nodeId', width:60,hide: true},
            { display:'上级ID', name:'parentNode', width:60,hide: true},
            /* { display: '序号', width: 40, render: function (rowData, rowindex, value, column, rowid, page, pagesize) { return (page - 1) * pagesize + rowindex + 1; }}, */
            { display:'名称', name:'nodeName', align: 'center', width:120, editor: { type: 'text' }}
        ], url: _path + "/list/json?rnd=" + Math.random(), delayLoad: false, sortName:"ranking", sortOrder:"desc",
        pageSize: 30, pageSizeOptions: [20, 30, 50, 100], width: '100%', height: '100%', heightDiff: -1,checkbox:true
    });
});
function onSelect(note) {
    var manager = $("#mainGrid").ligerGetGridManager();
    manager.set('parms', {search_parentId: note.data.id, rnd: Math.random()});
    manager.loadData();
}
function onCancelselect(note) {
    var manager = $("#mainGrid").ligerGetGridManager();//alert(JSON2.stringify(note.data));
    manager.set('parms', {rnd: Math.random()});
    manager.loadData();
}
var parentId = "";
function f_load() {
    var manager = $("#mainGrid").ligerGetGridManager();
    manager.loadData(true);
}
/*
 * 确定选择角色，并组装数据
 * */
function f_organizationJson(){
    var manager = $("#mainGrid").ligerGetGridManager();
    var rows = manager.getCheckedRows();
    var roles = [];
    if (rows && rows.length > 0) {
        $(rows).each(function () {
            var hostJson = {id:this.nodeId,name:this.nodeName,code:this.code}
            roles.push(hostJson);
        });
    }
    return roles;
}
</script>
</html>